<template>
  <div>
    <a-button class="queryIsPaid" :disabled="timeVal != '订单信息校验'" type="primary" @click="onTime" icon="search">{{timeVal}}</a-button>
    <!-- <a-modal v-model="visible" title="重新获取支付流水" ok-text="查询" cancel-text="取消" @ok="hideModal" :confirmLoading="confirmLoading">
      <a-input v-model="inputVal"  placeholder="请输入当前订单订单号" />
    </a-modal> -->
  </div>
</template>
<script>
  import { getAction } from '@/api/manage'
  export default {
    props:['orderType','orderId'],
    data () {
      return {
        url:{
          hotel:'/order/queryIsPaid',
          mall:'/mall/order/queryIsPaid',
        },
        timeVal:'订单信息校验',
        // visible:false,
        // inputVal:'',
        // confirmLoading:false, //加载中
      }
    },
    methods:{
      //10秒内不能多次点击
      onTime(){
        this.timeVal = '请勿多次点击';
        this.queryIsPaid()
        setTimeout(()=>{
          this.timeVal = '订单信息校验';
        },5000)
      },
      //弹出对话框
      // modalShow(){
      //   this.visible = true;
      // },
      //隐藏对话框
      // hideModal(){
      //   this.confirmLoading = true;
      //   if(this.inputVal == this.orderId){
      //     this.queryIsPaid()
      //   }else{
      //     this.$message.warning('订单号错误');
      //   }
      // },
      queryIsPaid(){
        let url = '';
        if(this.orderType == 1){
          url = this.url.hotel
        }else if(this.orderType == 2){
          url = this.url.mall
        }
        let params = {
          orderId: this.orderId,
        }
        getAction(url, params).then((res) => {
          if(res.result[0]){
            this.$message.success('重新获取成功,已经支付')
            this.$emit('ok')
          }else{
            this.$message.warning('重新获取成功,尚未查询到付款信息')
          }
        }).finally(() => {
          this.confirmLoading = false;
          this.visible = false;
          this.inputVal = "";
        })
      },
    }
  }
</script>
<style scoped>
  .queryIsPaid{
    margin-bottom: 10px;
  }
</style>